<template>
	<!-- 司机编辑 -->
	<div>
		<div class="edit-top">
			编辑信息
			<i class="el-icon-close" @click='cancel'></i>
		</div>
		<div class="edit-content">
			<div class="edit-title">司机信息</div>
			<div class="edit-item">
				<label>昵称</label><input v-model="info.nickname" type="text" />
			</div>
			<div class="edit-item">
				<label>生日</label><input v-model="info.birthday" type="text" />
			</div>
			<div class="edit-item">
				<label>城市</label><input v-model="info.city" type="text" />
			</div>
			<div class="edit-item">
				<label>职业</label><input v-model="info.job" type="text" />
			</div>
			<div class="edit-item">
				<label>联系方式</label><input v-model="info.phone" type="text" />
			</div>
			<div class="edit-item">
				<label>性别</label><select v-model="info.sex">
					<option value="0">未知</option>
					<option value="1">男</option>
					<option value="2">女</option>
				</select>
			</div>
			<!-- <div class="edit-item">
				<label>生日</label><select v-model="info.birthday">
					<option v-for="item in enterprise_list" :value="item.id">{{item.enterpriseName}}</option>
				</select>
			</div>
			<div class="edit-item">
				<label>所属角色</label>				
				<span v-if="role_list.length <= 0">未设置角色</span>
				<template>
				  <el-checkbox-group v-model="info.roleIds">
				    <el-checkbox v-for='item in role_list' :key='item.id' :label="item.id">{{item.roleName}}</el-checkbox>
				  </el-checkbox-group>
				</template>
			</div>
			<div class="edit-item">
				<label>邮箱</label><input v-model="info.email" type="text" />
			</div>
			<div class="edit-item">
				<label>客户证件类型</label><select v-model="info.identityType">
					<option v-for='item in dict.identityType' :value="item.value">{{item.type}}</option>
				</select>
			</div>
			<div class="edit-item">
				<label>客户证件号码</label><input v-model="info.identityNum" type="text" />
			</div>
			<div class="edit-item">
				<label>联系手机</label><input v-model="info.mobileNum" type="text" />
			</div>
			<div class="edit-item">
				<label>客户状态</label><select v-model="info.clientStatus">
					<option v-for='item in dict.clientStatus' :value="item.value">{{item.type}}</option>
				</select>
			</div>
			<div class="edit-title">用户信息</div>
			<div class="edit-item">
				<label>昵称</label><input v-model="info.sysUser.chineseName" type="text" />
			</div>
			<div class="edit-item">
				<label>用户名</label><input v-model="info.sysUser.userName" type="text" />
			</div>
			<div class="edit-item">
				<label>密码</label><input v-model="info.sysUser.userPassword" type="text" />
			</div>
			<div class="edit-item">
				<label>用户类型</label><select v-model="info.sysUser.userType">
					<option v-for='item in dict.userType' :value="item.value">{{item.type}}</option>
				</select>
			</div>
			<div class="edit-item">
				<label>用户状态</label><select v-model="info.sysUser.userStatus">
					<option v-for='item in dict.userStatus' :value="item.value">{{item.type}}</option>
				</select>
			</div> -->
		</div>
		<div class="edit-bottom">
			<span @click='cancel'>取消</span>
			<el-button @click='save' type="primary">保存</el-button>
		</div>
	</div>
</template>

<script>
	import Global from '@/components/Global.vue'
	export default {
		props: ['id'],
		data() {
			return {
				dict: '',
				enterprise_list: [],
				role_list: [],

				info: {

				},
			}
		},
		mounted() {

			this.get_info();
		},
		methods: {
			get_info() {
				var self = this;
				this.$axios.get(this.$global.serverIp + 'frontend/consumerUser/detail?id=' + this.id)
					.then(function(res) {
						if (res != '') {
							self.info = res.data;
						}
					})
			},
			save() {
				var self = this;
				this.$axios.post(this.$global.serverIp + 'frontend/consumerUser/update', self.info)
					.then(function(res) {
						if (res != '') {
							self.success('编辑成功');
						}
					})
			},
			success(content) {
				var self = this;
				this.$alert(content, '提示', {
					confirmButtonText: '确定',
					callback: action => {
						self.$emit("saveEdit", 2);
					}
				});
			},
			cancel() {
				this.$emit("saveEdit", 1);
			}
		}
	}
	import '@/assets/css/edit.css'
</script>
